import { defineConfig, loadEnv } from "vite";
import { resolve } from "path";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  const root = process.cwd()
  const env = loadEnv(mode, root)
  return {
    base: process.env.NODE_ENV === 'development' ? '/' : '/',
    resolve: {
      alias: {
        "@": resolve(__dirname, "./src"),
      },
    },
    assetsInclude: ['public/china.json'],
    server: {
      host: '0.0.0.0',
      public: '10.18.8.71:80',
      port: 80,
      proxy: {
        '/wechat': {
          target: 'https://dwzxl.dwstock.com',
          ws: false,
          changeOrigin: true,
          pathRewrite: {
            '/wechat': '/wechat'
          }
        },
        '^/hussarApi': {
          target: 'http://10.18.8.38:8280/',
          changeOrigin: true, //开启代理
        },
        '^/chart': {
          target: 'https://echarts.apache.org',
          changeOrigin: true, //开启代理
          rewrite: (path) => path.replace(/^\/chart/, ""),
        }
      },
    },
    plugins: [vue()],
  };
});
